package com.pay.alipay.utils;

import lombok.Data;

import java.sql.Time;

/**
 * 统一返回对象
 */
@Data
public class BaseResult {
 //返回的状态码
    private int status;

    private String msg;

    private Object data;

    private long time=System.currentTimeMillis();

    public static BaseResult createBaseResult(int status,String msg,Object data){
        BaseResult baseResult=new BaseResult();
        baseResult.setStatus(status);
        baseResult.setMsg(msg);
        baseResult.setData(data);
        return baseResult;
    }

    //返回成功方法
    public  static BaseResult success(){
        return BaseResult.createBaseResult(SysConstant.STATUS_SUCCESS,SysConstant.SUCCESS_MESSAGE,null);
    }

    public  static BaseResult success(Object result){
        return BaseResult.createBaseResult(SysConstant.STATUS_SUCCESS,SysConstant.SUCCESS_MESSAGE,result);
    }
    public  static BaseResult success(String message,Object result){
        return BaseResult.createBaseResult(SysConstant.STATUS_SUCCESS,message,result);
    }
    public  static BaseResult fail(){
        return BaseResult.createBaseResult(SysConstant.STATUS_FAIL,SysConstant.FAIL_MESSAGE,null);
    }
    public  static BaseResult fail(Object result){
        return BaseResult.createBaseResult(SysConstant.STATUS_FAIL,SysConstant.FAIL_MESSAGE,result);
    }
    public  static BaseResult fail(String message,Object result){
        return BaseResult.createBaseResult(SysConstant.STATUS_FAIL,message,result);
    }
}
